public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	CheckPlayerBounds(playerid);
	switch(dialogid)
	{
		case WEAPON_DIALOGID_MAIN:
		{
			if(response == 0) return GetPlayerControllable(playerid)?TogglePlayerControllable(playerid, true):1;
			switch(listitem)
			{
				case 0: // melee
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MELEE, WEAPON_MENU_MELEE);
				case 1: //pistols
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_PISTOLS, WEAPON_MENU_PISTOLS);
				case 2: //shotguns
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_SHOTGUN, WEAPON_MENU_SHOTGUN);
				case 3: //submachine
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_UZIS, WEAPON_MENU_UZIS);
				case 4: //machine
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_SUBMACH, WEAPON_MENU_SUBMACH);
				case 5: // armour
				{
					SetPlayerArmour(playerid, 100.0);
					GivePlayerMoney(playerid, -300);
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
			}
		}
		case WEAPON_DIALOGID_MELEE:
		{
			if(response == 0) return ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
			switch(listitem)
			{
				case 0:
				{// nitestick
					GivePlayerWeapon(playerid, WEAPON_NITESTICK, 13);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_NITESTICK]));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}/*
				case 1:
				{ // shovel
					GivePlayerWeapon(playerid, WEAPON_SHOVEL, 13);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_SHOVEL]));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}*/
				case 1:
				{// chainsaw
					GivePlayerWeapon(playerid, WEAPON_CHAINSAW, 13);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_CHAINSAW]));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
				case 2:
				{// knife
					GivePlayerWeapon(playerid, WEAPON_KNIFE, 13);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_KNIFE]));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
				case 3:
				{// golf
					GivePlayerWeapon(playerid, WEAPON_GOLFCLUB, 13);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_GOLFCLUB]));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
				case 4:
				{// katana
					GivePlayerWeapon(playerid, WEAPON_KATANA, 13);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_KATANA]));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
				case 5:
				{// cue
					GivePlayerWeapon(playerid, WEAPON_POOLSTICK, 13);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_POOLSTICK]));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
				case 6:
				{ //cane
					GivePlayerWeapon(playerid, WEAPON_CANE, 13);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_CANE]));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
				case 7:
				{ //bat
					GivePlayerWeapon(playerid, WEAPON_BAT, 13);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_BAT]));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
				case 8:
				{ //d1
					GivePlayerWeapon(playerid, WEAPON_DILDO, 13);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_DILDO]));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
				case 9:
				{ //d2
					GivePlayerWeapon(playerid, WEAPON_DILDO2, 13);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_DILDO2]));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
				case 10:
				{ //v1
					GivePlayerWeapon(playerid, WEAPON_VIBRATOR, 13);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_VIBRATOR]));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
				case 11:
				{ //v2
					GivePlayerWeapon(playerid, WEAPON_VIBRATOR2, 13);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_VIBRATOR2]));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
				case 12:
				{ // para
					GivePlayerWeapon(playerid, WEAPON_PARACHUTE, 13);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_PARACHUTE]));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
			}
		}
		case WEAPON_DIALOGID_PISTOLS:
		{
			if(response == 0) return ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
			switch(listitem)
			{
				case 0:
				{ // 9mm
					GivePlayerWeapon(playerid, WEAPON_COLT45, 34);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_COLT45]/PRICE_COUNT*34));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
				case 1:
				{ // silenced
					GivePlayerWeapon(playerid, WEAPON_SILENCED, 34);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_SILENCED]/PRICE_COUNT*34));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
				case 2:
				{ // deagle
					GivePlayerWeapon(playerid, WEAPON_DEAGLE, 21);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_DEAGLE]/PRICE_COUNT*21));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
			}
		}
		case WEAPON_DIALOGID_SHOTGUN:
		{
			if(response == 0) return ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
			switch(listitem)
			{
				case 0:
				{ // shotgun
					GivePlayerWeapon(playerid, WEAPON_SHOTGUN, 30);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_SHOTGUN]/PRICE_COUNT*30));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
				case 1:
				{ // sawnoff
					GivePlayerWeapon(playerid, WEAPON_SAWEDOFF, 28);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_SAWEDOFF]/PRICE_COUNT*28));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
				case 2:
				{// comb
					GivePlayerWeapon(playerid, WEAPON_SHOTGSPA, 21);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_SHOTGSPA]/PRICE_COUNT*21));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
			}
		}
		case WEAPON_DIALOGID_UZIS:
		{
			if(response == 0) return ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
			switch(listitem)
			{
				case 0:
				{// uzi
					GivePlayerWeapon(playerid, WEAPON_UZI, 100);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_UZI]/PRICE_COUNT*100));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
				case 1:
				{ // tec
					GivePlayerWeapon(playerid, WEAPON_TEC9, 100);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_TEC9]/PRICE_COUNT*100));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
				case 2:
				{ // mp 5
					GivePlayerWeapon(playerid, WEAPON_MP5, 60);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_MP5]/PRICE_COUNT*60));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
			}
		}
		case WEAPON_DIALOGID_SUBMACH:
		{
			if(response == 0) return ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
			switch(listitem)
			{
				case 0:
				{ // ak
					GivePlayerWeapon(playerid, WEAPON_AK47, 60);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_AK47]/PRICE_COUNT*60));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
				case 1:
				{ // m4
					GivePlayerWeapon(playerid, WEAPON_M4, 60);
					GivePlayerMoney(playerid, -abs(gunprice[WEAPON_M4]/PRICE_COUNT*60));
					ShowPlayerDialog(playerid, WEAPON_DIALOGID_MAIN, WEAPON_MENU_MAIN);
				}
			}
		}
		#if defined _dini_included || defined mxini_inc
		case LOGIN_DIALOGID_LOGIN:
		{
			new pwd[32], ufile[32];
			//new serial[40];
			#if defined mxini_inc
			new ufileid;
			#endif
			if(response == 0 || isnull(inputtext))
			{
				if(GetPlayerControllable(playerid)) TogglePlayerControllable(playerid, true);
				SendInternalNotify("Login/GUI: Refuse login", playerid, 0);
				return true;
			}
			format(ufile, sizeof(ufile), USER_PATH, GetFormattedName(playerid));
			#if defined mxini_inc
			ufileid = ini_openFile(ufile);
			if(ufileid == INI_FILE_NOT_FOUND)
				return true; // not registered
			else if(ufileid < 0)
				return SendCriticalError("R/W Error in GUI Login", playerid, ufileid);//return SendClientMessage(playerid, COLOR_ERROR, "R/W Error!");
			ini_getString(ufileid, "password", pwd);
			#else
			pwd = dini_Get(ufile, "password");
			#endif
			if(!strcmd(inputtext, pwd))
			{
				#if defined mxini_inc
				SendInternalNotify("Login/GUI: Wrong password", playerid, ufileid);
				#else
				SendInternalNotify("Login/GUI: Wrong password", playerid, 0);
				#endif
				SendClientMessage(playerid, COLOR_ERROR, "Wrong password!");
				if(GetPlayerControllable(playerid))
					TogglePlayerControllable(playerid, true);
				ShowPlayerDialog(playerid, LOGIN_DIALOGID_WRONG, LOGIN_MENU_WRONG);
				#if defined mxini_inc
				ini_closeFile(ufileid);
				#endif
				return true;
			}
			SetPlayerLogged(playerid, true);
			SendClientMessage(playerid, COLOR_YELLOW, "Login successful.");

			GetPlayerIp(playerid,pwd,sizeof(pwd));
			//gpci(playerid, serial, sizeof(serial));

			#if defined mxini_inc
			ini_setString(ufileid, "lastip", pwd);
			//ini_setString(ufileid, "lastserial", serial);
			ini_closeFile(ufileid);
			#else
			dini_Set(ufile, "lastip", pwd);
			//dini_Set(ufile, "lastserial", serial);
			#endif
			ReadUserData(playerid);
			if(GetPlayerControllable(playerid))
				TogglePlayerControllable(playerid, true);
		}
		case LOGIN_DIALOGID_REGISTER:
		{
			if(response == 0 || isnull(inputtext))
			{
				if(GetPlayerControllable(playerid)) TogglePlayerControllable(playerid, true);
				SendInternalNotify("Register/GUI: Refuse register", playerid, 0);
				return true;
			}
			new ufile[64];
			//new plip[16], serial[40];
			#if defined mxini_inc
			new ufileid;
			#endif
			format(ufile, sizeof(ufile), USER_PATH, GetFormattedName(playerid));
			//GetPlayerIp(playerid,plip,sizeof(plip));
			//gpci(playerid, serial, sizeof(serial));
			#if defined mxini_inc
			ufileid = ini_createFile(ufile, "");
			if(ufileid < 0)
				return SendCriticalError("R/W Error in GUI Register", playerid, ufileid);
			ini_setString(ufileid, "password", inputtext);
			//ini_setString(ufileid, "lastip", plip);
			//ini_setString(ufileid, "lastserial", serial);
			ini_closeFile(ufileid);
			#else
			dini_Create(ufile);
			dini_Set(ufile, "password", inputtext);
			//dini_Set(ufile, "lastip", plip);
			//dini_Set(ufile, "lastserial", serial);
			//dini_IntSet(ufile, "money", GetPlayerMoney(playerid));
			#endif
			SetPlayerLogged(playerid, true); WriteUserData(playerid); SetPlayerLogged(playerid, false);
			format(ufile, sizeof(ufile), "Register successful. Name: %s, Password: %s.", GetFormattedName(playerid), inputtext);
			SendClientMessage(playerid, COLOR_YELLOW, ufile);
			if(IsPlayerSpawned(playerid))
				SendClientMessage(playerid, COLOR_YELLOW, "Now you can /login.");
			else
				SetPlayerLogged(playerid, true);
			if(GetPlayerControllable(playerid))
				TogglePlayerControllable(playerid, true);
		}
		case LOGIN_DIALOGID_WRONG:
		{
			if(response)
			{
				ShowPlayerDialog(playerid, LOGIN_DIALOGID_LOGIN, LOGIN_MENU_LOGIN);
				TogglePlayerControllable(playerid, false); // ?
			}
			else if(GetPlayerControllable(playerid))
				TogglePlayerControllable(playerid, true);


		}
		#endif
		case FS_DIALOGID_FSMAIN:
		{
			if(response) SetPlayerFightStyleEx(playerid, listitem);
			return GetPlayerControllable(playerid)?TogglePlayerControllable(playerid, true):1;
		}
		case FS_DIALOGID_SKIN:
		{
			if(response)
			{
				new skinid = strval(inputtext);
				if(IsValidSkin(skinid))
				{
					SetPlayerSkin(playerid, skinid);
					SetSpawnInfo(playerid, 0, skinid, PLAYER_DEFSPAWN, PLAYER_DEFWEAPONS);
					if(IsPlayerInAnyVehicle(playerid))
						StopPlayer(playerid, 2.0);
					#if defined _dini_included || defined mxini_inc
					WriteUserData(playerid, RW_MASK_SKIN);
					#endif
				}
				else
					SendClientMessage(playerid, COLOR_ERROR, "Invalid skin id!");
			}
			return GetPlayerControllable(playerid)?TogglePlayerControllable(playerid, true):1;
		}
		#if defined walk_inc
		case FS_DIALOGID_WALKSTYLE:
		{
			if(response) SetPlayerWalkingStyle(playerid, listitem);
			return GetPlayerControllable(playerid)?TogglePlayerControllable(playerid, true):1;
		}
		#endif
		case OTH_DIALOGID_CAP:
		{
			if(!response) return true;
			switch(listitem)
			{
				case 0: // godmode
				{
					godmod[playerid] = !godmod[playerid];
					OnPlayerCommandText(playerid, "/h");
				}
				case 1: // hk
					hkctrl[playerid] = !hkctrl[playerid];
				case 2: // jump
					setbool(superjump, playerid, !getbool(superjump, playerid));
				case 3: // nogoto
					setbool(superjump, playerid, !getbool(nogoto, playerid));
				case 4: // skin
				{
					TogglePlayerControllable(playerid, false);
					ShowPlayerDialog(playerid, FS_DIALOGID_SKIN, FS_MENU_SKIN);
					return true;
				}
				case 5: // fs
				{
					TogglePlayerControllable(playerid, false);
					ShowPlayerDialog(playerid, FS_DIALOGID_FSMAIN, FS_MENU_FSMAIN);
					return true;
				}
				case 6: // ws
				{
					#if defined walk_inc
					TogglePlayerControllable(playerid, false);
					ShowPlayerDialog(playerid, FS_DIALOGID_WALKSTYLE, FS_MENU_WALKSTYLE);
					#else // e.g. anderius
					SendClientMessage(playerid, COLOR_ERROR, "Sorry, walking styles are not implented.");
					#endif
					return true;
				}
			}
			#if defined _dini_included || defined mxini_inc
			WriteUserData(playerid, RW_MASK_OPT);
			#endif
			BuildCap(playerid);
			return true;
		}
	}
	return false;
}
